
* Table A4: Sensitivity of IGE Estimates to Minimum Income Thresholds
clear
use "${data_dir}DavisMazumderData.dta"

keep if age_firstSurvey<=18
drop if miss0_old | miss1_old
drop if (mom_outOfRange==1 & linkMom==1 & !(dad_outOfRange==0 & linkDad==1)) | (dad_outOfRange==1 & linkDad==1 & !(mom_outOfRange==0 & linkMom==1)) | (linkMom==0 & linkDad==0) 
 

* --- *
* IGE *
* --- *

reg lfaminc1_oldbase loginc66_oldbase loginc79_oldbase surv79 women [w=weight], cluster(hhid)
eststo IGE_oldbase
test loginc66_oldbase=loginc79_oldbase
estadd scalar p = r(p): IGE_oldbase
gen s=e(sample)
count if surv79==0 & s==1
estadd scalar N66 = r(N): IGE_oldbase
count if surv79==1 & s==1
estadd scalar N79 = r(N): IGE_oldbase
drop s
lincom loginc79_oldbase-loginc66_oldbase
estadd scalar diff = r(estimate): IGE_oldbase
estadd scalar se = r(se): IGE_oldbase
global ige_main_est = r(estimate)
global ige_main_se = r(se)
	
reg lfaminc1_oldbase loginc66_oldbase loginc79_oldbase surv79  [w=weight] if women==1, cluster(hhid)
eststo IGE_oldbase_w
test loginc66_oldbase=loginc79_oldbase
estadd scalar p = r(p): IGE_oldbase_w
gen s=e(sample)
count if surv79==0 & s==1
estadd scalar N66 = r(N): IGE_oldbase_w
count if surv79==1 & s==1
estadd scalar N79 = r(N): IGE_oldbase_w
drop s
lincom loginc79_oldbase-loginc66_oldbase
estadd scalar diff = r(estimate): IGE_oldbase_w
estadd scalar se = r(se): IGE_oldbase_w
global ige_main_est = r(estimate)
global ige_main_se = r(se)
	
reg lfaminc1_oldbase loginc66_oldbase loginc79_oldbase surv79  [w=weight] if women==0, cluster(hhid)
eststo IGE_oldbase_m
test loginc66_oldbase=loginc79_oldbase
estadd scalar p = r(p): IGE_oldbase_m
gen s=e(sample)
count if surv79==0 & s==1
estadd scalar N66 = r(N): IGE_oldbase_m
count if surv79==1 & s==1
estadd scalar N79 = r(N): IGE_oldbase_m
drop s
lincom loginc79_oldbase-loginc66_oldbase
estadd scalar diff = r(estimate): IGE_oldbase_m
estadd scalar se = r(se): IGE_oldbase_m
global ige_main_est = r(estimate)
global ige_main_se = r(se)	
	


foreach min in 0 1000 1500 2500 {
	
	reg ltot1_min`min' ltot0_min`min'_66 ltot0_min`min'_79 surv79 women [w=weight], cluster(hhid)
	eststo IGE_`min'
	test ltot0_min`min'_66=ltot0_min`min'_79
	estadd scalar p = r(p): IGE_`min'
	gen s=e(sample)
	count if surv79==0 & s==1
	estadd scalar N66 = r(N): IGE_`min'
	count if surv79==1 & s==1
	estadd scalar N79 = r(N): IGE_`min'
	drop s
	lincom ltot0_min`min'_79-ltot0_min`min'_66
	estadd scalar diff = r(estimate): IGE_`min'
	estadd scalar se = r(se): IGE_`min'
	global ige_main_est = r(estimate)
	global ige_main_se = r(se)
	
	reg ltot1_min`min' ltot0_min`min'_66 ltot0_min`min'_79 surv79  [w=weight] if women==1, cluster(hhid)
	eststo IGE_`min'_w
	test ltot0_min`min'_66=ltot0_min`min'_79
	estadd scalar p = r(p): IGE_`min'_w
	gen s=e(sample)
	count if surv79==0 & s==1
	estadd scalar N66 = r(N): IGE_`min'_w
	count if surv79==1 & s==1
	estadd scalar N79 = r(N): IGE_`min'_w
	drop s
	lincom ltot0_min`min'_79-ltot0_min`min'_66
	estadd scalar diff = r(estimate): IGE_`min'_w
	estadd scalar se = r(se): IGE_`min'_w
	global ige_main_est = r(estimate)
	global ige_main_se = r(se)
	
	reg ltot1_min`min' ltot0_min`min'_66 ltot0_min`min'_79 surv79  [w=weight] if women==0, cluster(hhid)
	eststo IGE_`min'_m
	test ltot0_min`min'_66=ltot0_min`min'_79
	estadd scalar p = r(p): IGE_`min'_m
	gen s=e(sample)
	count if surv79==0 & s==1
	estadd scalar N66 = r(N): IGE_`min'_m
	count if surv79==1 & s==1
	estadd scalar N79 = r(N): IGE_`min'_m
	drop s
	lincom ltot0_min`min'_79-ltot0_min`min'_66
	estadd scalar diff = r(estimate): IGE_`min'_m
	estadd scalar se = r(se): IGE_`min'_m
	global ige_main_est = r(estimate)
	global ige_main_se = r(se)
	
}

#delimit ;
estout IGE_oldbase IGE_0 IGE_1000 IGE_1500 IGE_2500
	using  "${results_dir}tableA4.txt", replace
	keep(ltot0_min0_66 ltot0_min0_79) 
	rename(loginc66_oldbase ltot0_min0_66 ltot0_min1000_66 ltot0_min0_66 ltot0_min1500_66 ltot0_min0_66 ltot0_min2500_66 ltot0_min0_66
		loginc79_oldbase ltot0_min0_79 ltot0_min1000_79 ltot0_min0_79  ltot0_min1500_79 ltot0_min0_79 ltot0_min2500_79 ltot0_min0_79)
	cells(b(star fmt(3))  se(par fmt(3))) 
	collabels(,none) stat(p N66 N79 diff se) stardrop(*) ;	
	
estout IGE_oldbase_w IGE_0_w IGE_1000_w IGE_1500_w IGE_2500_w
	using  "${results_dir}tableA4.txt", append
	keep(ltot0_min0_66 ltot0_min0_79) 
	rename(loginc66_oldbase ltot0_min0_66 ltot0_min1000_66 ltot0_min0_66 ltot0_min1500_66 ltot0_min0_66 ltot0_min2500_66 ltot0_min0_66
		loginc79_oldbase ltot0_min0_79 ltot0_min1000_79 ltot0_min0_79  ltot0_min1500_79 ltot0_min0_79 ltot0_min2500_79 ltot0_min0_79)
	cells(b(star fmt(3))  se(par fmt(3))) 
	collabels(,none) stat(p N66 N79 diff se) stardrop(*) ;	
	
estout IGE_oldbase_m IGE_0_m IGE_1000_m IGE_1500_m IGE_2500_m
	using  "${results_dir}tableA4.txt", append
	keep(ltot0_min0_66 ltot0_min0_79) 
	rename(loginc66_oldbase ltot0_min0_66 ltot0_min1000_66 ltot0_min0_66 ltot0_min1500_66 ltot0_min0_66 ltot0_min2500_66 ltot0_min0_66
		loginc79_oldbase ltot0_min0_79 ltot0_min1000_79 ltot0_min0_79  ltot0_min1500_79 ltot0_min0_79 ltot0_min2500_79 ltot0_min0_79)
	cells(b(star fmt(3))  se(par fmt(3))) 
	collabels(,none) stat(p N66 N79 diff se) stardrop(*) ;	
	
#delimit cr	

